﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CsharpWpfManual
{
    /// <summary>
    /// myPopup.xaml 的交互逻辑
    /// </summary>
    public partial class myPopup : UserControl
    {
        public myPopup()
        {
            InitializeComponent();
            readDataTimer.Tick += new EventHandler(timeCycle);
            readDataTimer.Interval = new TimeSpan(0, 0, 0, 5);
        }

        private static System.Windows.Threading.DispatcherTimer readDataTimer = new System.Windows.Threading.DispatcherTimer();
        public void timeCycle(object sender, EventArgs e)
        {
            if (pp.IsOpen == true)
            {
                pp.IsOpen = false;
            }
            readDataTimer.IsEnabled = false;

        }
        /// <summary>
        /// opend事件，打开后，启动定时器开始计时，先写死5秒把
        /// </summary>
        private void pp_Opened(object sender, EventArgs e)
        {
            readDataTimer.IsEnabled = true;

            readDataTimer.Start();
        }


        public void ShowMessage(string message)
        {
            pp.IsOpen = true;
            txt.Text = message;
        }
    }
}
